package com.ruoyi.project.oms.paeaAuTypePointRel.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.oms.paeaAuTypePointRel.domain.PaeaAuTypePointRel;
import com.ruoyi.project.oms.paeaAuTypePointRel.service.IPaeaAuTypePointRelService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 监控类型监控点关系Controller
 *
 * @author 关晓强
 * @date 2020-03-14
 */
@Controller
@RequestMapping("/oms/paeaAuTypePointRel")
public class PaeaAuTypePointRelController extends BaseController
{
    private String prefix = "oms/paeaAuTypePointRel";

    @Autowired
    private IPaeaAuTypePointRelService paeaAuTypePointRelService;

    @RequiresPermissions("oms:paeaAuTypePointRel:view")
    @GetMapping()
    public String paeaAuTypePointRel()
    {
        return prefix + "/paeaAuTypePointRel";
    }

    /**
     * 查询监控类型监控点关系列表
     */
    @RequiresPermissions("oms:paeaAuTypePointRel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaAuTypePointRel paeaAuTypePointRel)
    {
        startPage();
        List<PaeaAuTypePointRel> list = paeaAuTypePointRelService.list(new QueryWrapper<PaeaAuTypePointRel>(paeaAuTypePointRel));
        return getDataTable(list);
    }

    /**
     * 导出监控类型监控点关系列表
     */
    @RequiresPermissions("oms:paeaAuTypePointRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaAuTypePointRel paeaAuTypePointRel)
    {
        List<PaeaAuTypePointRel> list = paeaAuTypePointRelService.list(new QueryWrapper<PaeaAuTypePointRel>(paeaAuTypePointRel));
        ExcelUtil<PaeaAuTypePointRel> util = new ExcelUtil<PaeaAuTypePointRel>(PaeaAuTypePointRel.class);
        return util.exportExcel(list, "paeaAuTypePointRel");
    }

    /**
     * 新增监控类型监控点关系
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存监控类型监控点关系
     */
    @RequiresPermissions("oms:paeaAuTypePointRel:add")
    @Log(title = "监控类型监控点关系", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaAuTypePointRel paeaAuTypePointRel)
    {
        return toAjax(paeaAuTypePointRelService.saveOrUpdate(paeaAuTypePointRel));
    }

    /**
     * 修改监控类型监控点关系
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaAuTypePointRel paeaAuTypePointRel = paeaAuTypePointRelService.getById(id);
        mmap.put("paeaAuTypePointRel", paeaAuTypePointRel);
        return prefix + "/edit";
    }

    /**
     * 修改保存监控类型监控点关系
     */
    @RequiresPermissions("oms:paeaAuTypePointRel:edit")
    @Log(title = "监控类型监控点关系", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaAuTypePointRel paeaAuTypePointRel)
    {
        return toAjax(paeaAuTypePointRelService.saveOrUpdate(paeaAuTypePointRel));
    }

    /**
     * 删除监控类型监控点关系
     */
    @RequiresPermissions("oms:paeaAuTypePointRel:remove")
    @Log(title = "监控类型监控点关系", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaAuTypePointRelService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
